ACIAC   EQU     $8001               location of the onboard 6850 serial interface control reg
ACIAD   EQU     ACIAC+2             location of the onboard 6850 serial interface data reg
RDRF    EQU     0
TDRE    EQU     1
MEMTST  EQU     $4C00               Location of memory where 1/2 KB will b tested

        ORG     $4A00               originate at $4A00

START   MOVE.L	#$00000000,$4602    RESET CLOCK
        MOVE.L  #$004F,D6           move count to D6 for total number of tests
LOOPK   LEA     MEMTST,A0           LOAD testing address to A0
        MOVE    #1023,D2            MOVE 1024 to D2 to test 1 KB of RAM
LOOPB   BSR     CHECK
        MOVE.B  #20,D1
        TRAP    #0
        MOVE.B  D0,(A0)             MOVE it to byte in testing area
        MOVE.B  #20,D1
        TRAP    #0
        ADD.B   D0,(A0)             Add random number to current byte
        MOVE.B  #20,D1
        TRAP    #0
        SUB.B   D0,(A0)             subtract random number from current byte
        MOVE.B  #20,D1
        TRAP    #0
        CLR.L   D4                  clear d4
        MOVE.B  (A0),D4             move current byte to d4
        MULU    D0,D4               multiply random number by d4
        MOVE.B  D4,(A0)             return byte to memory
        MOVE.B  #20,D1
        TRAP    #0
        CLR.L   D4                  clear d4
        MOVE.B  (A0),D4             move current byte to d4
        DIVU    D0,D4               divide d4 by random number
        MOVE.B  D4,(A0)             return byte to memory
        MOVE.B  #20,D1
        TRAP    #0
        AND.B   D0,(A0)             AND random number with current byte
        NOT.B   (A0)                negate current byte
        MOVE.B  #20,D1
        TRAP    #0
        OR.B    D0,(A0)+            or random number with current byte and increment byte
        DBF     D2,LOOPB            Branch to test next byte
        DBF     D6,LOOPK            branch to repeat test
        MOVE.B  #19,D1              MOVe 19 to d1
        TRAP    #0                  get current time
        MOVE.B  #2,D1               Move 2 to d1
        TRAP    #0                  print newline
        LEA     RAMTST,A4           load finished string
        MOVE.B  #4,D1               move 4 to d1
        TRAP    #0                  print finished string
        MOVE.B  #11,D1              move 11 to d1
        TRAP    #0                  print long hex number in D0
        LEA     UNITS,A4            load units string to A4
        MOVE.B  #4,D1               move 4 to d1
        TRAP    #0                  print units
        TRAP    #15                 warm reset
*
CHECK   BTST.B  #RDRF,ACIAC         test receiver status
        BRA.S   CHECKE		        poll until receiver has data
        MOVE.B  ACIAD,D0            put data in D0
        MOVE.B  #18,D1
        TRAP    #0
CHECKE  RTS
RAMTST  DC.B    'RAM Test Finished in $',0,0    String to print at end
UNITS   DC.B    ' Hundredths of seconds.',0     units of the time

        END     START
        


*~Font name~Courier New~
*~Font size~10~
*~Tab type~1~
*~Tab size~8~
